using System;
using System.Data;

using Wicresoft.Common;

namespace Wicresoft.Busi.Entity
{
	[Table("MeetingRoomDevice", "ID", "Busi.ConnectionString")]
	public class MeetingRoomDevice : Info
	{
		#region SQL column name consts 
		public const string SQLCOL_ID = "ID";
		public const string SQLCOL_ROOMID = "RoomID";
		public const string SQLCOL_DEVICENAME = "DeviceName";
		public const string SQLCOL_DCOUNT = "DCount";
		public const string SQLCOL_DESCRIPTION = "Description";
		#endregion


		#region Contructors
		/// <summary>
		/// Construct empty entity
		/// </summary>
		public MeetingRoomDevice () {}

		/// <summary>
		/// Construct entity by primary key, other fields will be assigned by 
		/// "Load" method.
		/// </summary>
		public MeetingRoomDevice (int ID)
		{
			this.ID = ID;
		}
		#endregion

		public override void Init (DataRow row)
		{
			ID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_ID]);
			RoomID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_ROOMID]);
			DeviceName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_DEVICENAME]);
			DCount = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_DCOUNT]);
			Description = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_DESCRIPTION]);
		}

		#region Properties 
		#region Property <int> ID
		[Property("ID", 4, SqlDbType.Int, true, true)]
		public int ID 
		{
			get { return _ID; }
			set { _ID = value; }
		}
		private int _ID = int.MinValue;
		#endregion

		#region Property <int> RoomID
		[Property("RoomID", 4, SqlDbType.Int, false, false)]
		public int RoomID 
		{
			get { return _RoomID; }
			set { _RoomID = value; }
		}
		private int _RoomID = int.MinValue;
		#endregion

		#region Property <string> DeviceName
		[Property("DeviceName", 200, SqlDbType.NVarChar, false, false)]
		public string DeviceName 
		{
			get { return _DeviceName; }
			set { _DeviceName = value; }
		}
		private string _DeviceName = null;
		#endregion

		#region Property <int> DCount
		[Property("DCount", 4, SqlDbType.Int, false, false)]
		public int DCount 
		{
			get { return _DCount; }
			set { _DCount = value; }
		}
		private int _DCount = int.MinValue;
		#endregion

		#region Property <string> Description
		[Property("Description", 1000, SqlDbType.NVarChar, false, false)]
		public string Description 
		{
			get { return _Description; }
			set { _Description = value; }
		}
		private string _Description = null;
		#endregion
		#endregion


		public bool LoadByIdentity(int ID)
		{
			return DataAccess.SelectByIdentity(this, Convert.ToInt64(ID));
		}


		public bool DeleteByIdentity()
		{
			return DataAccess.DeleteByIdentity(this);
		}
	}
}
